package com.donleo.task.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author liangd
 * date 2020-12-15 10:49
 * code 异步任务
 */
@Service
public class AsyncService {
    /**
     * 开启异步，加上这个注解就不会等待3s时间
     */
    @Async
    public void hello(){
        try {
            System.out.println("数据处理中....");
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
